1680881120886_ingredients.ts ➔ up   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 16
c 0
b 0
f 0
rs 9.8
cc 1
1
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
2
3
export default class extends BaseSchema {
4
  protected tableName = 'ingredients'
5
6
  public async up () {
7
    this.schema.createTable(this.tableName, (table) => {
8
      table.increments('id')
9
      table.integer('user_id').unsigned().references('users.id').onDelete('CASCADE')
10
      table.string('name').unique()
11
      table.string('quantity_available')
12
      table.string('quantity_supplied')
13
      table.string('quantity_stocked')
14
      table.string('last_reorder_at') //@bug updates value automatically when set as timestamp
15
16
      /**
17
       * Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
18
       */
19
      table.timestamp('created_at', { useTz: true })
20
      table.timestamp('updated_at', { useTz: true })
21
    })
22
  }
23
24
  public async down () {
25
    this.schema.dropTable(this.tableName)
26
  }
27
}
28